package com.example.bms.user.service.impl;

import com.example.bms.user.entity.StaffEntity;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.common.utils.PageUtils;
import com.example.common.utils.Query;

import com.example.bms.user.dao.StaffinfoDao;
import com.example.bms.user.entity.StaffinfoEntity;
import com.example.bms.user.service.StaffinfoService;
import org.springframework.util.ObjectUtils;


@Service("staffinfoService")
public class StaffinfoServiceImpl extends ServiceImpl<StaffinfoDao, StaffinfoEntity> implements StaffinfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<StaffinfoEntity> page = this.page(
                new Query<StaffinfoEntity>().getPage(params),
                new QueryWrapper<StaffinfoEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils login(Map<String, Object> params) {
        QueryWrapper<StaffinfoEntity> queryWrapper=new QueryWrapper<StaffinfoEntity>();
        String user =(String) params.get("username");
        String pass =(String) params.get("password");


        if(!ObjectUtils.isEmpty(user)&&!ObjectUtils.isEmpty(pass)){
            queryWrapper.eq("user",user).
                    eq("pass",pass);
        }

        IPage<StaffinfoEntity> page = this.page(
                new Query<StaffinfoEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}